#pragma once

// CChSServer command target

class CChSServer : public CAsyncSocket
{
public:
	static CChSServer* Instance();
	static BOOL Initialize();
	static void Uninitialize();
	virtual ~CChSServer();

	BOOL Start(const CString& strHost, UINT uPort);
	void Stop();
	void SendToAll(const CString& strMessage);

	BOOL RemoveClient(const CChSClientContext *pClientContext);
	BOOL FindClient(const CString& strUserName);
	BOOL SendToClientUsersList(CChSClientContext *pClientContext);
	void UpdateClientsList();

	BOOL Started() const { return m_bStarted; }

protected:
	virtual void OnAccept(int nErrorCode);

private:
	CChSServer();
	static CChSServer* s_pInstance;

	vector<CChSClientContext*> m_ClientsArr;
	BOOL m_bStarted;	
};


